﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.Common;
using System.Xml;
using System.Xml.XPath;
using System.Xml.Xsl;
using System.IO;
using System.Diagnostics;
using GenericLibrary.Xml;

namespace GenericLibrary.Xml.Xsl {

    public class ClrObjectWrapper : XPathNavigator {

        private object _clrObject;

        public ClrObjectWrapper( object clrObject ) {
            this._clrObject = clrObject;
        }

        public override string BaseURI {
            get {
                return string.Empty;
            }
        }

        public override XPathNavigator Clone() {
            return new ClrObjectWrapper( this._clrObject );
        }

        public override bool IsEmptyElement {
            get {
                return true;
            }
        }

        public override bool IsSamePosition( XPathNavigator other ) {
            ClrObjectWrapper _other = other as ClrObjectWrapper;
            return _other != null && _other._clrObject == this._clrObject;
        }

        public override string LocalName {
            get {
                return string.Empty;
            }
        }

        public override bool MoveTo( XPathNavigator other ) {
            try {
                ClrObjectWrapper _other = other as ClrObjectWrapper;
                if( _other != null ) {
                    this._clrObject = _other._clrObject;
                    return true;
                }
                return false;
            } catch( Exception ) {
                Debug.Assert( false );
                throw;
            }
        }

        public override bool MoveToFirstAttribute() {
            return false;
        }

        public override bool MoveToFirstChild() {
            return false;
        }

        public override bool MoveToFirstNamespace( XPathNamespaceScope namespaceScope ) {
            return false;
        }

        public override bool MoveToId( string id ) {
            return false;
        }

        public override bool MoveToNext() {
            return false;
        }

        public override bool MoveToNextAttribute() {
            return false;
        }

        public override bool MoveToNextNamespace( XPathNamespaceScope namespaceScope ) {
            return false;
        }

        public override bool MoveToParent() {
            return false;
        }

        public override bool MoveToPrevious() {
            return false;
        }

        public override string Name {
            get {
                return string.Empty;
            }
        }

        public override XmlNameTable NameTable {
            get {
                return null;
            }
        }

        public override string NamespaceURI {
            get {
                return string.Empty;
            }
        }

        public override XPathNodeType NodeType {
            get {
                return XPathNodeType.Root;
            }
        }

        public override string Prefix {
            get {
                return string.Empty;
            }
        }

        public override string Value {
            get {
                return null;
            }
        }

        public override object UnderlyingObject {
            get {
                return this._clrObject;
            }
        }
    }
}
